<style type="text/css">
.ddtable tr td {
	text-align: center !important;
}
.ddtable .control-label {
	width: 100% !important;
	text-align: left !important;
}
</style>
<div class="ibox">
	<div class="ibox-content">
		<form class="form-horizontal" id="addForm"
			action="${cxt!}/message/smsPlugin/pluginRecive/add" method="POST">
			<div class="form-group">
				<label for="namebasic" class="col-md-2 control-label">${_res["smsApiConfig.smsName"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-md-3">
					<input type="text" class="form-control" name="smsPluginConfig.name" placeholder="${_res['smsApiConfig.smsName']}" required aria-required="true">
				</div>

				<label for="namebasic" class="col-md-2 control-label">${_res["smsApiConfig.apiclassname"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-md-3">
					<input type="text" class="form-control" name="smsPluginConfig.apiclassname" placeholder="${_res['smsApiConfig.apiclassname']}" required aria-required="true">
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="form-group">
				<label class="col-sm-2 control-label">${_res["smsApiConfig.default"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-sm-3">
					<#dict type="select" class="form-control" name="smsPluginConfig.defaultvalue" dictCode="COMMON_YN" required="true" />
				</div>
				
				<label class="col-md-2 control-label">${_res["smsApiConfig.numberOfTimesToSend"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-md-3">
					<input type="text" class="form-control" name="smsPluginConfig.sendnum" placeholder="${_res['smsApiConfig.numberOfTimesToSend']}" 
					   required aria-required="true" number="true" />
				</div>
			</div>
			
			<div class="hr-line-dashed"></div>

			<div class="form-group">
				
				<label class="col-sm-2 control-label">${_res["smsApiConfig.status"]}<span class="fontColorRed">&nbsp;*</span></label>
				<div class="col-sm-3">
					<#dict type="select" class="form-control" name="smsPluginConfig.status" dictCode="COMMON_STATUS" required="true" />
				</div>
				
			    <label for="namebasic" class="col-md-2 control-label">${_res["smsApiConfig.description"]}</label>
				<div class="col-md-3">
					<input type="text" class="form-control" name="smsPluginConfig.description" placeholder="${_res['smsApiConfig.description']}">
				</div>				
			</div>
			<div class="hr-line-dashed"></div>

			<div class="row searchLineWrap">
				<p>
					<a href="javascript:void(0);" class="btn btn-primary pull-left" id="btn">${_res["smsApiConfig.addSms"]}</a>
					<div class="clearfix"></div>
				</p>
				<table class="table table-bordered table-hover ddtable" id="table">
					<thead>
						<tr>
							<th width="10%" style="display: none"></th>
							<th width="30%">${_res["smsApiConfig.parameterDescription"]}</th>
							<th width="20%">${_res["smsApiConfig.parameterName"]}</th>
							<th width="20%">${_res["smsApiConfig.parameterValue"]}</th>
							<th width="10%">${_res["smsApiConfig.whetherToLose"]}</th>
							<th>${_res["articleCatalog.sortValue"]}</th>
							<th>${_res["system.operator"]}</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td style="display: none"></td>
							<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.description" value=""  required aria-required="true"/></div></td>
							<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.name" value=""  required aria-required="true"/></div></td>
							<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.value" value=""  required aria-required="true"/></div></td>
							<td><div><#dict type="radio" name="smsPluginConfigAttribute1.required" dictCode="COMMON_YN"  defaultValue="Y"/></div></td>
							<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.orders" value="" /></div></td>
							<td>
								<a href="javascript:void(0);" class="btn btn-primary pull-center" onclick="removeRow(this);" id="btn">${_res["system.delete"]}</a>
							</td>
						</tr>
					</tbody>
				</table>
			</div>

			<div class="form-group">
				<div class="col-md-10 col-md-offset-2">
					<button type="button" class="btn btn-warning" onClick="ajaxContent('/message/smsPlugin/pluginRecive/list')">${_res["system.return"]}</button>
					<button type="submit" class="btn btn-primary">${_res["system.save"]}</button>
					<button type="button" class="btn btn-danger" onClick="ajaxContent('/message/smsPlugin/pluginRecive/list')">${_res["system.cancel"]}</button>
				</div>
			</div>
		</form>
	</div>
</div>

<!-- 动态添加的table  start -->
<table class="table table-bordered table-hover ddtable" id="copyTable" style="display:none">
	<tbody>
		<tr>
			<td style="display: none"></td>
			<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.description" value=""  required aria-required="true"/></div></td>
			<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.name" value=""  required aria-required="true"/></div></td>
			<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.value" value=""  required aria-required="true"/></div></td>
			<td><div><#dict type="radio" name="smsPluginConfigAttribute1.required" dictCode="COMMON_YN"  defaultValue="Y"/></div></td>
			<td><div><input type="text" class="control-label text-left" name="smsPluginConfigAttribute1.orders" value="" /></div></td>
			<td>
				<a href="javascript:void(0);" class="btn btn-primary pull-center" onclick="removeRow(this);" id="btn">${_res["system.delete"]}</a>
			</td>
		</tr>
	</tbody>
</table>
<!-- 动态添加的table  end -->

<#submit formId="addForm" divId="content" /> <#nav />

<script>
	$(function() {
		   //添加一行
		   $("#btn").bind("click",function() {
				//复制一行
				var $lastTR = $("#copyTable tbody tr").clone(true);
				$("#table tbody").append($lastTR);
				//添加序号	
				$("#table tr").each(function(i){
					  $(this).find("td:first-child").text(i);
				});
			    inputSelect();
		  });

		function inputSelect() {
			//input取name值和赋name值
			var rowIndex = 0;
			$("#table").each(function() {
				$(this).find("tr").find("input").each(function(i) {
					var inputName = $(this).attr("name");
					var inputNames = inputName.split(".");
					var name = inputNames[0];
					name = name.substring(0,name.length- ("" + name.match(/(\d+$)/g)).length);
					var key = inputNames[1];
					var rowIndex = $(this).parents("tr").find("td:first-child").text();
					var newInputName = name+ rowIndex + "."+ key;
					$(this).attr("name",newInputName);
				});
				
			})
		};
	});
	function removeRow(nowTr) {
		$(nowTr).parent().parent().remove();
	}
</script>